﻿package frEngine.animateControler.skilEffect
{
    import baseEngine.core.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.animateControler.*;
    import frEngine.animateControler.keyframe.*;
    import frEngine.core.*;
    import frEngine.core.mesh.*;

    public class SwordLightControler_Bone extends MeshAnimateBase
    {
        public var useTwoLine:Boolean = false;
        private var showLineNum:int = 3;
        private var showLineNumBase:Number = 3;
        public var splitNum:int = 8;
        private var swordMesh:SwordLightMesh_Bone;
        private var swordSurface:SwordLightSurface;
        public var length1:int = 0;
        public var offsetY:int = 100;
        public var rot:Vector3D;

        public function SwordLightControler_Bone()
        {
            return;
        }// end function

        public function initData(param1:int, param2:int, param3:Number, param4:int, param5:int, param6:int, param7:Vector3D = null) : void
        {
            this.useTwoLine = false;
            this.length1 = param1;
            this.offsetY = param5;
            this.splitNum = param6;
            if (this.splitNum < 1)
            {
                this.splitNum = 1;
            }
            if (!param7 || param7.length == 0)
            {
                param7 = new Vector3D(0, 0, 1);
            }
            this.rot = param7;
            var _loc_8:* = param4;
            this.showLineNumBase = param4;
            this.showLineNum = _loc_8;
            this.swordMesh.reInitPlaySwordLight();
            changeBaseValue(null, this.showLineNumBase);
            return;
        }// end function

        override protected function getBaseValue(param1:Pivot3D) : Object
        {
            return this.showLineNumBase;
        }// end function

        override protected function setTargetProperty(param1) : void
        {
            this.showLineNum = int(param1);
            return;
        }// end function

        override public function editKeyFrame(param1:Object, param2:int, param3:String, param4, param5:BezierVo) : Object
        {
            var _loc_6:* = super.editKeyFrame(param1, param2, param3, param4, param5);
            this.showLineNum = param4 + this.showLineNumBase;
            this.updateData();
            return _loc_6;
        }// end function

        override protected function setSurfaceHander(event:Event) : void
        {
            super.setSurfaceHander(event);
            this.swordSurface = targetSurface as SwordLightSurface;
            return;
        }// end function

        override public function set targetObject3d(param1:Pivot3D) : void
        {
            this.swordMesh = param1 as SwordLightMesh_Bone;
            super.targetObject3d = param1;
            return;
        }// end function

        override public function toUpdateAnimate(param1:Boolean = false) : void
        {
            super.toUpdateAnimate(param1);
            if (!this.swordMesh.toUpdate)
            {
                return;
            }
            this.swordMesh.toUpdate = false;
            this.updateData();
            return;
        }// end function

        private function updateData() : void
        {
            if (!this.swordMesh.curHangControler || !this.swordMesh.curHangControler.cuPlayLable || !this.swordSurface)
            {
                return;
            }
            var _loc_1:* = this.swordMesh.curHangControler.currentFrame;
            var _loc_2:* = this.swordSurface.actionTotalFrames;
            if (_loc_1 > _loc_2)
            {
                _loc_1 = _loc_2;
            }
            var _loc_3:* = this.showLineNum * this.splitNum * 2;
            var _loc_4:* = (_loc_1 - 1) * this.splitNum * 6 - _loc_3 * 3;
            if (_loc_4 < 0)
            {
                _loc_3 = _loc_3 + _loc_4 / 3;
                _loc_4 = 0;
            }
            this.swordMesh.boneFileter.swordUVOffset[0] = _loc_4 / 6 / this.swordSurface.totalNumLine;
            this.swordMesh.boneFileter.swordUVOffset[1] = this.swordSurface.totalTriangle / _loc_3;
            this.swordSurface.firstIndex = _loc_4;
            var _loc_5:* = _loc_3;
            this.swordSurface.indexBufferFr.numTriangles = _loc_3;
            return;
        }// end function

        override public function get type() : int
        {
            return AnimateControlerType.swordLight_Bone;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            this.swordMesh = null;
            this.swordSurface = null;
            super.dispose();
            return;
        }// end function

    }
}
